module IEEE_ARITHMETIC
implicit none

type, private :: IEEE_CLASS_TYPE
    private
    integer :: hidden
end type

interface IEEE_VALUE
    module procedure IEEE_VALUE_8
end interface
public :: IEEE_VALUE

contains

elemental real(kind=8) function IEEE_VALUE_8(X, CLASS) result(res)
    real(kind=8), intent(in) :: X
    type(IEEE_CLASS_TYPE), intent(in) :: CLASS

    select case (CLASS%hidden)
        case (1)
            res = -1
            res = sqrt(res)
        case (2)
            res = -1
            res = sqrt(res)
        case (3)
            res = huge(res)
            res = (-res) * res
        case (4)
            res = -43
        case (5)
            res = -tiny(res)
            res = res / 2
        case (6)
            res = 0
            res = -res
        case (7)
            res = 0
        case (8)
            res = tiny(res)
            res = res / 2
        case (9)
            res = 42
        case (10)
            res = huge(res)
            res = res * res
        case default
            res = 0
    end select
end function
end module IEEE_ARITHMETIC